# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=shellinabox
_daemonname=${pkgname}d
pkgver=2.21
pkgrel=1
pkgdesc="Implementation of a web server that can export arbitrary command line tools to a web based terminal emulator"
url="https://github.com/shellinabox/shellinabox"
arch="all"
license="GPL-2.0-or-later"
makedepends="autoconf automake m4 libtool openssl-dev zlib-dev"
subpackages="$pkgname-doc $pkgname-openrc"
pkgusers="$_daemonname"
pkggroups="$_daemonname"
install="$pkgname.pre-install"
source="http://slackware.co.nz/raspbian/raspbian/pool/main/s/$pkgname/${pkgname}_${pkgver}.tar.xz
	$pkgname.initd
	$pkgname.confd
	openssl-1.1.patch
	"
builddir="$srcdir/$pkgname"

prepare() {
	default_prepare
	cd "$builddir"
	autoreconf -i
}

build() {
	cd "$builddir"
	export CPPFLAGS="${CPPFLAGS/-D_FORTIFY_SOURCE=2/}"
	./configure \
		--prefix=/usr \
		--disable-static \
		--disable-utmp
	make
}

check() {
	cd "$builddir"
	make check
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir/" install
	install -D -m 755 "$srcdir/$pkgname.initd" "$pkgdir/etc/init.d/$_daemonname"
	install -D -m 644 "$srcdir/$pkgname.confd" "$pkgdir/etc/conf.d/$_daemonname"
	mkdir -p "$pkgdir"/var/run/$_daemonname
	chown $pkgusers:$pkggroups "$pkgdir"/var/run/$_daemonname
}

sha512sums="284ce2d76daa6a3c57060e380a777befd69870e5fce52311e8dcf4e55ac57fb265662d9194915aeed7c842d2e9f10f9ab5bf4e9ae0afebee6c7650219459cc2b  shellinabox_2.21.tar.xz
47206ce991f642e474387c5c00ee4fd8cae0c71da6075e3c62381bb75b46085c35767e817932da64a112b58535516fc620d089434e478c844b4cd7c62bdae654  shellinabox.initd
2e0ef340d88cd62cac4c7c073bdcb79e2e88c77aab7e310daa4ae8b27c297b6138262762dae1f054928f02b38d4a8185dd9b357fd3f59a635c04697fd620cfef  shellinabox.confd
b3dfc8642408b65f0b271a49500950480fcce6cb173009694882096a352d0db52f7beb4f82f886a5c5ce0c00bac23744939a8965312bfff74b6127e288846e7d  openssl-1.1.patch"
